


<!DOCTYPE html>
<html id="htmlId">
<head>
  <title>Coverage Report > PacKeyListener</title>
  <style type="text/css">
    @import "../../css/coverage.css";
    @import "../../css/idea.min.css";
  </style>
  <script type="text/javascript" src="../../js/highlight.min.js"></script>
  <script type="text/javascript" src="../../js/highlightjs-line-numbers.min.js"></script>
</head>

<body>
<div class="content">
<div class="breadCrumbs">
Current scope:     <a href="../../index.html">all classes</a>
    <span class="separator">|</span>
    <a href="../index.html">nl.tudelft.jpacman.ui</a>
</div>

<h1>Coverage Summary for Class: PacKeyListener (nl.tudelft.jpacman.ui)</h1>

<table class="coverageStats">
<tr>
  <th class="name">Class</th>
<th class="coverageStat 
">
  Class, %
</th>
<th class="coverageStat 
">
  Method, %
</th>
<th class="coverageStat 
">
  Line, %
</th>
</tr>
<tr>
  <td class="name">PacKeyListener</td>
<td class="coverageStat">
  <span class="percent">
    100%
  </span>
  <span class="absValue">
    (1/1)
  </span>
</td>
<td class="coverageStat">
  <span class="percent">
    40%
  </span>
  <span class="absValue">
    (2/5)
  </span>
</td>
<td class="coverageStat">
  <span class="percent">
    41.7%
  </span>
  <span class="absValue">
    (5/12)
  </span>
</td>
</tr>

</table>

<br/>
<br/>


<pre>
<code class="sourceCode" id="sourceCode">&nbsp;package nl.tudelft.jpacman.ui;
&nbsp;
&nbsp;import java.awt.event.KeyEvent;
&nbsp;import java.awt.event.KeyListener;
&nbsp;import java.util.Map;
&nbsp;
&nbsp;/**
&nbsp; * A key listener based on a set of keyCode-action pairs.
&nbsp; *
&nbsp; * @author Jeroen Roosen 
&nbsp; */
<b class="fc">&nbsp;class PacKeyListener implements KeyListener {</b>
&nbsp;
&nbsp;    /**
&nbsp;     * The mappings of keyCode to action.
&nbsp;     */
&nbsp;    private final Map&lt;Integer, Action&gt; mappings;
&nbsp;
&nbsp;    /**
&nbsp;     * Create a new key listener based on a set of keyCode-action pairs.
&nbsp;     * @param keyMappings The mappings of keyCode to action.
&nbsp;     */
<b class="fc">&nbsp;    PacKeyListener(Map&lt;Integer, Action&gt; keyMappings) {</b>
<b class="fc">&nbsp;        assert keyMappings != null;</b>
<b class="fc">&nbsp;        this.mappings = keyMappings;</b>
<b class="fc">&nbsp;    }</b>
&nbsp;
&nbsp;    @Override
&nbsp;    public void keyPressed(KeyEvent event) {
<b class="nc">&nbsp;        assert event != null;</b>
<b class="nc">&nbsp;        Action action = mappings.get(event.getKeyCode());</b>
<b class="nc">&nbsp;        if (action != null) {</b>
<b class="nc">&nbsp;            action.doAction();</b>
&nbsp;        }
<b class="nc">&nbsp;    }</b>
&nbsp;
&nbsp;    @Override
&nbsp;    public void keyTyped(KeyEvent event) {
&nbsp;        // do nothing
<b class="nc">&nbsp;    }</b>
&nbsp;
&nbsp;    @Override
&nbsp;    public void keyReleased(KeyEvent event) {
&nbsp;        // do nothing
<b class="nc">&nbsp;    }</b>
&nbsp;}
</code>
</pre>
</div>

<script type="text/javascript">
(function() {
    var msie = false, msie9 = false;
    /*@cc_on
      msie = true;
      @if (@_jscript_version >= 9)
        msie9 = true;
      @end
    @*/

    if (!msie || msie && msie9) {
      hljs.highlightAll()
      hljs.initLineNumbersOnLoad();
    }
})();
</script>

<div class="footer">
    
    <div style="float:right;">generated on 2023-04-11 19:46</div>
</div>
</body>
</html>
